*Abuse by Association

*This do file contains all main analyses presented in Abuse by Association.
	
*DVAR: Human rights abuses
*IVAR: migration from terror-prone countries


*Table 1-Correlation table-

			xtgee F.physint   lPerMigrantterror lPerMigrantterhigh lPerMigrantsfriterateany lPerMigrantsdiff  llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
		   asdoc corr lPerMigrantterror lPerMigrantterhigh lPerMigrantsfriterateany lPerMigrantsdiff  llnMigrants  if e(sample), save(corrl.doc) title(Correlation)

******Models in the Original Paper
*Replicates Table 2 in main text
{
		
		*Physint 
		*Baseline
			xtgee F.physint  llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
			outreg2 using DraftTable1,  replace  word excel label 
		*Add in Percent from countries with at least one terrorist attack 
			xtgee F.physint  lPerMigrantterror llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
			outreg2 using DraftTable1,  append word excel label 
		*Add in Percent from High-Terror Countries 
			xtgee F.physint  lPerMigrantterhigh llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
			outreg2 using DraftTable1,  append word excel label 
		*Add in Percent from states whose nationals conducted at least one trans event 
			xtgee F.physint lPerMigrantsfriterateany  llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
			outreg2 using DraftTable1,  append word excel label 
		*Add in Percent from different Russett civilization categories:
			xtgee F.physint  lPerMigrantsdiff llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
			outreg2 using DraftTable1,  append word excel label 
		*All indicators together
			xtgee F.physint   lPerMigrantterror lPerMigrantterhigh lPerMigrantsfriterateany lPerMigrantsdiff  llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
			outreg2 using DraftTable1,  append word excel label 
 
		
		}
		*FIGURES
			
		*Figure 1
		xtgee F.physint  lPerMigrantterror llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
		margins, atmeans at(lPerMigrantterror=(0(5)100)) vsquish
		marginsplot, recast(line) recastci(rarea) addplot(hist lPerMigrantterror if e(sample), fraction  yaxis(2))
		graph save lFigure1.gph, replace 

		*Figure 2
		xtgee F.physint  lPerMigrantterhigh llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
		margins, atmeans at(lPerMigrantterhigh=(0(5)100)) vsquish
		marginsplot, recast(line) recastci(rarea) addplot(hist lPerMigrantterhigh if e(sample), fraction  yaxis(2))
		graph save lFigure2.gph, replace 


		*Figure 3
		xtgee F.physint  lPerMigrantsfriterateany llnMigrants   polity2 lnGTD lngdp lnpop  civilwar internationalwar i.year , corr(ar1) force  robust
		margins, atmeans at(lPerMigrantsfriterateany=(0(5)100)) vsquish
		marginsplot, recast(line) recastci(rarea) addplot(hist lPerMigrantsfriterateany if e(sample), fraction  yaxis(2))
		graph save lFigure3.gph, replace 
